import { ActionFunctionArgs } from 'react-router-dom'

export default async ({ request }: ActionFunctionArgs) => {
  const formData = await request.formData()
  const data = Object.fromEntries(formData)
  const isRegistered = await window.api.shortCut(data.shortCut as string)
  if (isRegistered) {
    window.api.sql(`update config set content=@content where id=1`, 'update', {
      content: JSON.stringify(data),
    })
  }
  return {}
}
